package com.bootdo.system.controller;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bootdo.common.utils.PageUtils;
import com.bootdo.common.utils.Query;
import com.bootdo.common.utils.ShiroUtils;
import com.bootdo.system.domain.RoleDO;
import com.bootdo.system.domain.TbWithdrawal;
import com.bootdo.system.domain.UserDO;
import com.bootdo.system.service.RoleService;
import com.bootdo.system.service.TxService;


@RequestMapping("/txgl")
@Controller
public class TxController {
	
	@Autowired
	private TxService txService;
	
	@Autowired
	private RoleService roleService;
	
	String prefix = "system/txgl";
	
	@GetMapping()
	String task() {
		return prefix + "/txgl";
	}
	
	/**
	 * 查询所有提现记录
	 */
	@ResponseBody
	@GetMapping("/list")
	public PageUtils searchTaskList(@RequestParam Map<String, Object> params) {
		UserDO user = ShiroUtils.getUser();
		List<RoleDO> list2 = roleService.getRoleByUserId(user.getUserId());
		boolean falg=false;
		for (RoleDO role : list2) {
			if(role.getRoleId() == 59L) {
				falg=true;
			}
		}
		if(falg) {
			params.put("deptId", user.getDeptId());
		}else {
			params.put("sid", user.getUserId());
		}
		Query query = new Query(params);
		 List<TbWithdrawal> list = txService.list(query);
		 int count = txService.count(query);
		 PageUtils pageUtil = new PageUtils(list, count);
		 return pageUtil;
	}

}
